package com.it.commicity.controller.sys;


import com.it.commicity.common.Result;
import com.it.commicity.domain.po.SysMenu;
import com.it.commicity.domain.po.SysUser;
import com.it.commicity.service.sys.ISysMenuService;
import com.it.commicity.utils.UserHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 菜单权限表 前端控制器
 * </p>
 * menu/menus
 *
 * @author author
 * @since 2025-07-11
 */
@RestController
@RequestMapping("/api")
public class SysMenuController {
    @Autowired
    private ISysMenuService menuService;

    /**
     * 获取侧边栏数据
     *
     * @return
     */
    @GetMapping("/menu/menus")
    public Result<List<SysMenu>> getMenuTree() {
        SysUser user = UserHolder.getUser();
        List<SysMenu> menuTree = menuService.getMenuTree(user.getUserId());
        return Result.success(menuTree);
    }
}
